import java.io.File;
import java.util.Iterator;
import java.util.List;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.junit.Test;

import com.google.code.wifimaps.core.xmlparser.AiroSystemOutContentHandler;
import com.google.code.wifimaps.entidade.WifiNetwork;



public class XMLParserAiroTestCase {

	@Test
	public void ParseFile() throws Exception {
		try {
			SAXParserFactory parserFactory = SAXParserFactory.newInstance();
			SAXParser parser = parserFactory.newSAXParser();
			AiroSystemOutContentHandler handler = new AiroSystemOutContentHandler();
			
			parser.parse(new File("test/sample.xml"), handler);
			
			List<WifiNetwork> wifiList = handler.getWifiList();
			
			System.out.println("No of NetWorks '" + wifiList.size() + "'.");

			Iterator<WifiNetwork> it = wifiList.iterator();
			while(it.hasNext()) {
				System.out.println(it.next().toString());
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
